package first.endtoend

import java.sql.Date

/**
 * Created with IntelliJ IDEA.
 * User: Olfa
 */

class Family implements Serializable
{

    String familyName
    String telephone
    static hasMany = [beneficiaries: Beneficiary]
    static belongsTo = [category: Category, fps: FairPricesShop]
    Portfolio portfolio
    RationCard rationCard
    Date dateCreated
    Date lastUpdated
    Address address
    //static  embedded = ['address']
    transient Beneficiary beneficiarySelected


    static constraints = {
        category nullable: false
        familyName nullable: false
        telephone nullable: true
        portfolio(nullable: true, unique: true)
        rationCard(nullable: true)
        fps(nullable: true)
        beneficiarySelected(nullable: true)
        familyName(unique: 'telephone')
        address(nullable: true, unique: true)

    }

    static mapping = {
        beneficiaries cascade: "all-delete-orphan"
        rationCard cascade: "delete"
        portfolio cascade: "delete"
        // address cascade: "delete"
    }

    /*  static searchFields = {
          familyName
      }*/

    @Override
    public String toString()
    {
        familyName
    }


}
